//
//  WorkHomeVC.m
//  XLDoctor
//
//  Created by longma on 2018/7/27.
//  Copyright © 2018年 XLH. All rights reserved.
//

#import "SelectTestItemAlertView.h"

static const CGFloat contentHeight = 550.0f;

@interface SelectTestItemAlertView ()

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentviewH;
@property (weak, nonatomic) IBOutlet UIView *contentview;
@property (weak, nonatomic) IBOutlet MJUIAlertVCBaseView *baseAlertView;
@property (weak, nonatomic) IBOutlet MJUIPickerItemAlertTopView *viewTop;
//
@property (weak, nonatomic) IBOutlet MJUIShadowView *uricAcidTestView;
@property (weak, nonatomic) IBOutlet MJUIShadowView *bloodGlucoseTestView;
@property (weak, nonatomic) IBOutlet MJUIShadowView *hemoglobinTestView;
@property (weak, nonatomic) IBOutlet MJUIShadowView *totalCholesterolTestView;

@end

@implementation SelectTestItemAlertView
#pragma mark - 系统

- (void)viewDidLoad {
    [super viewDidLoad];

    if(self.isGlobalDetection){
        self.contentviewH.constant = 300;
        self.baseAlertView.alertType = AlertTypeBottom;
        self.baseAlertView.contentHeight = 300;
        [self.baseAlertView initContentview:self.contentview];
        
        self.uricAcidTestView.hidden = true;
        self.bloodGlucoseTestView.hidden = true;
        self.hemoglobinTestView.hidden = true;
        self.totalCholesterolTestView.hidden = true;
        
        //
        NSString *detectionType = self.detectionValueModel.type;
        
        if ([detectionType isEqualToString:totalCholesterolType]) {
            self.totalCholesterolTestView.hidden = false;
        }
        if ([detectionType isEqualToString:bloodSugarType]) {
            self.bloodGlucoseTestView.hidden = false;
        }
        if ([detectionType isEqualToString:hemoglobinType]) {
            self.hemoglobinTestView.hidden = false;
        }
        if ([detectionType isEqualToString:bloodUricAcidType]) {
            self.uricAcidTestView.hidden = false;
        }
        
    }else{
        self.contentviewH.constant = contentHeight;
        self.baseAlertView.alertType = AlertTypeBottom;
        self.baseAlertView.contentHeight = contentHeight;
        [self.baseAlertView initContentview:self.contentview];
    }
    
    MJWeakSelf
    self.viewTop.contentView.backgroundColor = UIColor.mj_backgroundColor;
    self.viewTop.titleLabel.mj_localizable = @"Select Test Item";
    self.viewTop.titleLabelLeft.constant = 20;
    [self.viewTop.cancelButton mj_addAction:^(UIButton *button) {
        if(weakSelf.isGlobalDetection){
            [HealthHelper interruptionSaveAlertViewWithConfirmBlock:^{
                [weakSelf.baseAlertView dismiss];
            } cancelBlock:^{}];
        }else{
            [weakSelf.baseAlertView dismiss];
        }
    }];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
 
}

- (IBAction)handleItemButtonButtonEvent:(UIButton *)sender {

    MJWeakSelf
    [self.baseAlertView dismissCompletion:^{
        if(weakSelf.confirmBlock){
            weakSelf.confirmBlock(sender.tag);
        }
    }];
}


#pragma mark - 其他



@end
